package middleware

import (
	"fmt"
	"gitee.com/gzhtty_1824517828/go-gin-gorm/common"
	"github.com/gin-gonic/gin"
)

func JwtAuth() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		token := ctx.GetHeader("x-token")
		var apiResult common.ApiResult
		if token == "" {
			apiResult.Code = common.StatusBadRequest
			apiResult.Message = common.StatusText(common.StatusTokenError)
			apiResult.Payload = nil
			ctx.JSON(common.StatusTokenError, apiResult)
			return
		}
		//todo add verify token
		fmt.Println("token verify pass")
	}
}
